#include <WinTen.h>
#include <Windows.h>
#include <Extend.h>

void WindowBoxIn( HDC hDC, RECT * pRect );
void WndDrawBox( HDC hDC, RECT * rct, HPEN hPUpLeft, HPEN hPBotRit );

//----------------------------------------------------------------------------//

CLIPPER CREATEMENU()
{
   _retnl( ( LONG ) CreateMenu() );
}

//----------------------------------------------------------------------------//

CLIPPER CREATEPOPU()
{
   _retnl( ( LONG ) CreatePopupMenu() );
}

//----------------------------------------------------------------------------//

CLIPPER TRACKPOPUP()
{
  _retl( TrackPopupMenu( ( HANDLE ) _parnl( 1 ), _parni( 2 ), _parni( 4 ),
         _parni( 3 ), _parni( 5 ), ( HANDLE ) _parni( 6 ), NULL ) );
}

//----------------------------------------------------------------------------//

CLIPPER ENABLEMENU()   // ITEM()
{
   _retl( EnableMenuItem( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER CHECKMENUI()   // TEM()
{
   _retl( CheckMenuItem( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETMITEMCO()   // UNT()
{
   _retni( GetMenuItemCount( ( HMENU ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETMITEMID()    // hMenu, nPos
{
   _retni( GetMenuItemID( ( HMENU ) _parnl( 1 ), _parni( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETSYSTEMM()    // ENU()
{
   _retnl( ( LONG ) GetSystemMenu( ( HMENU ) _parnl( 1 ), _parl( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER DESTROYMEN()   //  U()   hMenu
{
   _retl( DestroyMenu( ( HMENU ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETSUBMENU()    // hMenu, nPos
{
   _retnl( ( LONG ) GetSubMenu( ( HMENU ) _parnl( 1 ), _parni( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETMENUSTR()    // ING()   hMenu, nId, nPosOrValue
{
   BYTE bBuffer[ 200 ];
   WORD wLen = GetMenuString( ( HMENU ) _parnl( 1 ), _parni( 2 ), bBuffer, 199,
                              _parni( 3 ) );

   _retclen( bBuffer, wLen );
}

//----------------------------------------------------------------------------//

CLIPPER GETMENUSTA()    // TE()   hMenu, nId, nFlags
{
   _retni( GetMenuState( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER DRAWMENUBA()    // R()    hWnd
{
   DrawMenuBar( ( HWND ) _parnl( 1 ) );
}

//----------------------------------------------------------------------------//

CLIPPER HILITEMENU()  // ITEM()  hWnd, hMenu, idItem, nHiliteFlags
{
   _retl( HiliteMenuItem( ( HWND ) _parnl( 1 ), ( HMENU ) _parnl( 2 ),
                          _parni( 3 ), _parni( 4 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER LOADMENU()
{
   _retnl( ( LONG ) LoadMenu( ( HANDLE ) _parnl( 1 ),
                              ( LPSTR ) IF( ISCHAR( 2 ), _parc( 2 ),
                              MAKEINTRESOURCE( _parni( 2 ) ) ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER APPENDMENU()
{
   _retl( AppendMenu( ( HMENU ) _parnl( 1 ), ( UINT ) _parni( 2 ), _parni( 3 ),
                    IF( ISCHAR( 4 ), _parc( 4 ), ( LPSTR ) _parnl( 4 ) ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER SETMENU()
{
   _retl( SetMenu( ( HWND ) _parnl( 1 ), ( HMENU ) _parnl( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER MODIFYMENU()
{
   _retl( ModifyMenu( ( HMENU ) _parnl( 1 ), ( UINT ) _parni( 2 ),
          _parni( 3 ), ( UINT ) _parni( 4 ),
          IF( ISCHAR( 5 ), _parc( 5 ), ( LPSTR ) _parnl( 5 ) ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER INSERTMENU() // ( hMenu, nIdItem, nFlags, nNewItem, cPrompt ) --> lSuccess
{
   _retl( InsertMenu( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ),
                      _parni( 4 ), _parc( 5 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER REMOVEMENU() // ( hMenu, nItem, nFlags ) --> lSuccess
{
   _retl( RemoveMenu( ( HMENU ) _parnl( 1 ),
                      ( UINT ) _parni( 2 ),
                      ( UINT ) _parni( 3 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER MENUDRAWIT() // EM( pDrawItemStruct, cPrompt )
{
   LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) _parnl( 1 );
   HPEN hNormal;

   switch( lpdis->itemAction )
   {
      case ODA_DRAWENTIRE:
           TextOut( lpdis->hDC, lpdis->rcItem.left + 3, lpdis->rcItem.top + 2,
                    ( LPSTR ) lpdis->itemData, 4 );
           _retl( TRUE );
           break;

      case ODA_SELECT:
           lpdis->rcItem.top++;
           lpdis->rcItem.left++;
           lpdis->rcItem.bottom--;
           lpdis->rcItem.right--;
           if( lpdis->itemState & ODS_SELECTED )
           {
              // WindowBoxIn( lpdis->hDC, &( lpdis->rcItem ) );
           }
           else
           {
              hNormal = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNFACE ) );
              // WndDrawBox( lpdis->hDC, &( lpdis->rcItem ), hNormal, hNormal );
              DeleteObject( hNormal );
           }
           _retl( TRUE );
           break;

      case ODA_FOCUS:
           _retl( FALSE );
           break;
   }
}

//----------------------------------------------------------------------------//

CLIPPER MENUMEASUR() // EITEM( pMeasureItemStruct )
{
  LPMEASUREITEMSTRUCT lp = ( LPMEASUREITEMSTRUCT ) _parnl( 1 );

  lp->itemWidth  = 58;
  lp->itemHeight = 17;
}

//----------------------------------------------------------------------------//

CLIPPER GETDRAWITE() // M( pDrawItemStruct ) --> nMenuItemID
{
}

//----------------------------------------------------------------------------//

CLIPPER ISMENU()
{
   _retl( IsMenu( ( HMENU ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//
